<?php

include './function/Pengguna.php';
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
session_start();
$key = $_GET['key_confirm'];
$login = $_GET['login'];

//cek key dan login
if ($key == '' || $login == '') {
    header("Location: http://semuaberbagi.com/daftar.php");
    exit();
}

//aktifasi user
$pengguna = new Pengguna();
$email = $pengguna->getEmail_With_Key_Confirm($key);
if ($pengguna->updateKey_Confirm($key) == true) {
    if ($login == 1) {
        header("Location: masuk.php");
        $_SESSION['cekMasuk']['status'] = "your account is now active";
        exit();
    } else {
        header("Location: pageUser.php");
        $_SESSION['user']['status'] = $email;
        exit();
    }
} else {
    header("Location: http://semuaberbagi.com/daftar.php");
    echo '<script>alert("Some error occur")</script>';
    exit();
}
